package com.yaozheng.vocationaltraining.dialog.ask;

import android.content.Context;
import android.view.Gravity;

import com.yaozheng.vocationaltraining.R;
import com.yaozheng.vocationaltraining.dialog.BaseDialog;
import com.yaozheng.vocationaltraining.fragment.BaseFragment;
import com.yaozheng.vocationaltraining.view.dialog.CancelAskDialogView;
import com.yaozheng.vocationaltraining.view.dialog.CancelAskDialogView_;

/**
 * 取消询问框
 */
public class CancelAskDialog extends BaseDialog {
    CancelAskDialogView carryOutAnAssignmentAskView;
    String runMethod;
    BaseFragment baseFragment;

    public CancelAskDialog(Context context) {
        super(context, R.style.baseDialogStyleTheme, true, Gravity.CENTER);
    }

    public CancelAskDialog(BaseFragment baseFragment) {
        this(baseFragment.getContext());
        this.baseFragment = baseFragment;
    }

    @Override
    public void setContentView() {
        carryOutAnAssignmentAskView = CancelAskDialogView_.build(getContext());
        carryOutAnAssignmentAskView.setBaseDialogEventProcess(this);

        setContentView(carryOutAnAssignmentAskView);
    }

    public void setContentValue(String value) {
        carryOutAnAssignmentAskView.setContentValue(value);
    }

    public void setTitileValue(String titileValue) {
        carryOutAnAssignmentAskView.setTitleValue(titileValue);
    }

    @Override
    public void initBaseDialog() {
        super.initBaseDialog();
        setCanceledOnTouchOutside(false);
    }

    public void setRunMethod(String runMethod) {
        this.runMethod = runMethod;
    }

    /**
     *  确定
     */
    public void determine() {
        cancel();
        if (runMethod == null) {
            return;
        }
        if (baseFragment != null) {
            baseFragment.runMethod(runMethod);
        } else {
            if (baseActivity != null) {
                baseActivity.runMethod(runMethod);
            }
        }
    }
}
